﻿using System;
using System.Linq;
using Se.Framework.Common.Extentions;
using Se.Framework.Web.Mvc.GenericCrud;
using Se.Framework.Web.Mvc.GenericCrud.Attributes;
using Trust.Casas.Web.Areas.Admin.Models;

namespace Trust.Casas.Web.Areas.Admin.Controllers.CustomGrid
{
    public class GridBuilderDefault<TMetadataType> : GridBuilderDefault
        where TMetadataType : class
    {
        public GridBuilderDefault()
            : base(typeof(TMetadataType).Attribute<GenericCrudTableDataAttribute>())
        {
        }

    }

    public class RegionGrigBuilder : GridBuilderDefault<RegionMetadata>
    {
        protected override System.Collections.Generic.IEnumerable<Trirand.Web.Mvc.JQGridColumn> ResolveColumns(bool requestingData)
        {
            var result = base.ResolveColumns(requestingData);

            //var column = result.First(p => p.DataField == "LocationPoint");
            //column.EditType = Trirand.Web.Mvc.EditType.DatePicker;
            //column.EditorControlID = "CrudDatePicker";
            //column.EditTypeCustomCreateElement = "createPointSelector";
            //column.EditTypeCustomGetValue = "getPointSelectorValue";
            return result;
        }
    }
}